<!--- 
	  
  Copyright (c) 2006, Chris Scott, Matt Woodward, Adam Wayne Lehman, Dave Ross
  All rights reserved.
	
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
       http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

  $Id: Entry.cfc 69 2006-10-20 15:22:29Z mpwoodward $

--->

<cfcomponent displayname="Entry" extends="net.litepost.component.NullableComponent"
	output="false" hint="A bean which models the Entry form.">

<!--- This bean was generated by the Rooibos Generator with the following template:
Bean Name: Entry
Path to Bean: net.litepost.component.entry
Extends: 
Call super.init(): false
Create cfproperties: false
Bean Template:
	entryID Numeric 
	categoryID Numeric 
	category String 
	title String 
	body String 
	entryDate Date 
	dateCreated Date 
	dateLastUpdated Date 
	numComments Numeric
	comments Array
Create getMemento method: false
Create setMemento method: false
Create setStepInstance method: false
Create validate method: false
Create validate interior: false
Date Format: MM/DD/YYYY
--->

	<!---
	PROPERTIES
	--->
	<cfset variables.instance = StructNew() />

	<!---
	INITIALIZATION / CONFIGURATION
	--->
	<cffunction name="init" access="public" returntype="net.litepost.component.entry.Entry" output="false">
		<cfargument name="entryID" type="Numeric" required="false" default="0" />
		<cfargument name="categoryID" type="Numeric" required="false" default="-1" />
		<cfargument name="category" type="string" required="false" default="" />
		<cfargument name="userID" type="string" required="false" default="0" />
		<cfargument name="userFirstName" type="string" required="false" default="" />
		<cfargument name="userLastName" type="string" required="false" default="" />
		<cfargument name="title" type="String" required="false" default="" />
		<cfargument name="body" type="String" required="false" default="" />
		<cfargument name="entryDate" type="Date" required="false" default="#Now()#" />
		<cfargument name="dateCreated" type="Date" required="false" default="#Now()#" />
		<cfargument name="dateLastUpdated" type="Date" required="false" default="#Now()#" />
		<cfargument name="numComments" type="Numeric" required="false" default="0" />
		<cfargument name="comments" type="Array" required="false" default="#arrayNew(1)#" />
		
		<!--- init parent --->
		<cfset super.init() />
		
		<!--- run setters --->
		<cfset setEntryID(arguments.entryID) />
		<cfset setCategoryID(arguments.categoryID) />
		<cfset setCategory(arguments.category) />
		<cfset setUserID(arguments.userID) />
		<cfset setUserFirstName(arguments.userFirstName) />
		<cfset setUserLastName(arguments.userLastName) />
		<cfset setTitle(arguments.title) />
		<cfset setBody(arguments.body) />
		<cfset setComments(arguments.comments) />
		<cfset setEntryDate(arguments.entryDate) />
		<cfset setDateCreated(arguments.dateCreated) />
		<cfset setDateLastUpdated(arguments.dateLastUpdated) />
		<cfset setNumComments(arguments.numComments) />
		<cfset setComments(arguments.comments) />

		<cfreturn this />
 	</cffunction>
	
	<!--- Return instance data for debugging --->
	<cffunction name="getInstance" access="public" returntype="struct" output="false">
		<cfreturn variables />
	</cffunction>
	
	<!--- validate the required fields --->
	<cffunction name="validate" access="public" returntype="boolean" output="false">
		<cfif len(getTitle()) and len(getBody()) and getCategoryID() GT -1>
			<cfreturn true />
		<cfelse>
			<cfreturn false />
		</cfif>
	</cffunction>
	
	<!---
	ACCESSORS
	--->
	<cffunction name="setEntryID" access="public" returntype="void" output="false">
		<cfargument name="entryID" type="Numeric" required="true" />
		<cfset variables.instance.entryID = arguments.entryID />
	</cffunction>
	<cffunction name="getEntryID" access="public" returntype="Numeric" output="false">
		<cfreturn variables.instance.entryID />
	</cffunction>

	<cffunction name="setCategoryID" access="public" returntype="void" output="false">
		<cfargument name="categoryID" type="Numeric" required="true" />
		<cfset variables.instance.categoryID = arguments.categoryID />
	</cffunction>
	<cffunction name="getCategoryID" access="public" returntype="Numeric" output="false">
		<cfreturn variables.instance.categoryID />
	</cffunction>

	<cffunction name="setCategory" access="public" returntype="void" output="false">
		<cfargument name="category" type="String" required="true" />
		<cfset variables.instance.category = arguments.category />
	</cffunction>
	<cffunction name="getCategory" access="public" returntype="String" output="false">
		<cfreturn variables.instance.category />
	</cffunction>

	<cffunction name="setUserID" access="public" returntype="void" output="false">
		<cfargument name="userID" type="numeric" required="true" />
		<cfset variables.instance.userID = arguments.userID />
	</cffunction>
	<cffunction name="getUserID" access="public" returntype="numeric" output="false">
		<cfreturn variables.instance.userID />
	</cffunction>

	<cffunction name="setUserFirstName" access="public" returntype="void" output="false">
		<cfargument name="userFirstName" type="String" required="true" />
		<cfset variables.instance.userFirstName = arguments.userFirstName />
	</cffunction>
	<cffunction name="getUserFirstName" access="public" returntype="String" output="false">
		<cfreturn variables.instance.userFirstName />
	</cffunction>

	<cffunction name="setUserLastName" access="public" returntype="void" output="false">
		<cfargument name="userLastName" type="String" required="true" />
		<cfset variables.instance.userLastName = arguments.userLastName />
	</cffunction>
	<cffunction name="getUserLastName" access="public" returntype="String" output="false">
		<cfreturn variables.instance.userLastName />
	</cffunction>

	<cffunction name="getPostedBy" access="public" returntype="String" output="false">
		<cfreturn getUserFirstName() &  " " & getUserLastName() />
	</cffunction>

	<cffunction name="setTitle" access="public" returntype="void" output="false">
		<cfargument name="title" type="String" required="true" />
		<cfset variables.instance.title = arguments.title />
	</cffunction>
	<cffunction name="getTitle" access="public" returntype="String" output="false">
		<cfreturn variables.instance.title />
	</cffunction>

	<cffunction name="setBody" access="public" returntype="void" output="false">
		<cfargument name="body" type="String" required="true" />
		<cfset variables.instance.body = arguments.body />
	</cffunction>
	<cffunction name="getBody" access="public" returntype="String" output="false">
		<cfreturn variables.instance.body />
	</cffunction>

	<cffunction name="setEntryDate" access="public" returntype="void" output="false">
		<cfargument name="entryDate" type="Date" required="true" />
		<cfset variables.instance.entryDate = arguments.entryDate />
	</cffunction>
	<cffunction name="getEntryDate" access="public" returntype="Date" output="false">
		<cfreturn variables.instance.entryDate />
	</cffunction>

	<cffunction name="setDateCreated" access="public" returntype="void" output="false">
		<cfargument name="dateCreated" type="Date" required="true" />
		<cfset variables.instance.dateCreated = arguments.dateCreated />
	</cffunction>
	<cffunction name="getDateCreated" access="public" returntype="Date" output="false">
		<cfreturn variables.instance.dateCreated />
	</cffunction>

	<cffunction name="setDateLastUpdated" access="public" returntype="void" output="false">
		<cfargument name="dateLastUpdated" type="Date" required="true" />
		<cfset variables.instance.dateLastUpdated = arguments.dateLastUpdated />
	</cffunction>
	<cffunction name="getDateLastUpdated" access="public" returntype="Date" output="false">
		<cfreturn variables.instance.dateLastUpdated />
	</cffunction>
	
	<cffunction name="setNumComments" access="public" returntype="void" output="false">
		<cfargument name="numComments" type="Numeric" required="true" />
		<cfset variables.instance.numComments = arguments.numComments />
	</cffunction>
	<cffunction name="getNumComments" access="public" returntype="Numeric" output="false">
		<cfreturn variables.instance.numComments />
	</cffunction>
	
	<cffunction name="setComments" access="public" returntype="void" output="false">
		<cfargument name="comments" type="Array" required="true" />
		<cfset variables.instance.comments = arguments.comments />
	</cffunction>
	<cffunction name="getComments" access="public" returntype="Array" output="false">
		<cfreturn variables.instance.comments />
	</cffunction>
	
</cfcomponent>